<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/4/19 0019
 * Time: 上午 10:30
 */
class User  extends Base_Controller
{
    private $user_id;

    private  $page_limit = 10;

    private $url;

    Const COMMENTS_PIC = "E:\\";

    Const CERTIFICATE_PIC = "E:\\";

    Const IDENTITY_PIC = "E:\\";


    public function __construct()
    {
        parent::__construct();
        $this->load->model('userv2info_model');
        $this->load->model('userchat_model');
        $this->load->model('userv2_model');
        $this->load->model('apporder_model');
        $this->load->model('notice_model');
        $this->load->model('apporderlog_model');
        $this->load->model('appordershensu_model');
        $this->load->model('trackcomments_model');
        $this->load->model('userv2mobile_model');
        $this->load->library('Myusersubscribe');
        $this->user_type = 'guider';
        $this->load->library('MyEmail');
        $this->load->library('MySms');
        $this->load->helper('captcha');
        $this->config = $this->config->item('base_url');
        if(!isset($_SESSION)){
            session_start();
        }
        if($_SESSION['is_login'] != 1) $this->error('未登录');

        $this->user_id = $_SESSION['uid'];

    }

    /**
     * 基本信息
     */
    public function index()
    {
        $userv2info = $this->userv2info_model->getUserV2Info(array('uvu.uid' => $this->user_id));

        $this->success(array('data' => $userv2info));
    }

    /**
     * 我的订单
     */
    public function myorderlist()
    {
        //页码
        $page = 1;
        if(isset($_GET['page']) && is_numeric($_GET['page'])){
            $page = $_GET['page'];
        }
        $offset = ($page - 1) * $this->page_limit;

        //每页数量
        if(!isset($_GET['size']) || !is_numeric($_GET['size'])){
            $limit = $this->page_limit;
        }else{
            $limit = $_GET['size'];
        }

        if(isset($_GET['status']) && is_numeric($_GET['status']) && $_GET['status'] == 1){
            $orderlist = $this->apporder_model->orderlist('uid = '.$this->user_id.' and status in (0,1,2,3,4,5,7,31,99)', $offset, $limit);
        }else{
            $orderlist = $this->apporder_model->orderlist('uid = '.$this->user_id.' and status in (6,32)', $offset, $limit);
        }

        $this->success(array('data' => $orderlist, 'page' => $page));
    }

    /**
     * 订单详情
     */
    public function myorderdetail()
    {
        if(!isset($_GET['id']) || !is_numeric($_GET['id'])) $this->error('order id not be null');
        $orderDetail = $this->apporder_model->orderDetail(array('ao.uid' => $this->user_id, 'ao.id' => $_GET['id']));

        $this->success(array('data' => $orderDetail));
    }

    /**
     * 申请退款
     */
    public function shensu()
    {
        $orderId = isset($_POST['order_id']) && is_numeric($_POST['order_id']) ? $_POST['order_id'] : null;
        if(!$orderInfo = $this->apporder_model
            ->orderDetail(array('ao.uid' => $this->user_id, 'ao.id' => $orderId))) $this->error('这不是你的订单！');
        if($orderInfo['status_id'] != 3) $this->error("订单发起申诉时,状态无效: status=".$orderInfo['status_id']);

        $res = $this->apporder_model->updateOrder(array('status' => 31), array('id' => $orderId, 'uid' => $this->user_id));
        if($res){
            if($shensu = $this->appordershensu_model->getShensu(array('orderId' => $orderId))){
                $this->appordershensu_model->editShensu(array('shensuStatus' => '未处理'), array('id' => $shensu['id']));
            }else{
                $this->appordershensu_model->addShensu(array('orderId' => $orderId,
                                                            'shensuStatus' => '未处理',
                                                            'handleTime' => NULL,
                                                            'shensuCreated' => time()
                                                            ));
            }
            $this->apporderlog_model->addOrderLog(array('orderId' => $orderId,'log' =>"游客向哇吖发出申诉",'created' => time()));
            $this->apporderlog_model->addOrderLog(array('orderId' => $orderId,'log' =>"哇吖接受游客的申诉申请，并会尽快与游客取得联系",'created' => time()));

            $guider = $this->userv2_model->getUser(array('uid' => $orderInfo['shopId']));
            $startDay = $orderInfo['startDay'];
            $endDay = $orderInfo['stopDay'];
            $title = $orderInfo['title'];
            $touristName = $orderInfo['userName'];
            $guiderName = $guider['userName'];
            $tourist_id = $this->user_id;
            $guider_id = $guider['uid'];
            $guider_msg = "{$touristName}针对{$startDay}至{$endDay}的行程《{$title}》向您发出了申诉，哇吖将在近期协调处理";
            $tourist_msg = "哇吖已收到您关于{$guiderName}提供的{$startDay}至{$endDay}的行程《{$title}》的申诉，哇吖将在近期协调处理";
            $this->notice_model->addNotice(array('sendUser' => $tourist_id, 'receiveUser' => $guider_id,
                                                 'message' =>$guider_msg , 'created' => time()));
            $this->notice_model->addNotice(array('sendUser' => $tourist_id, 'receiveUser' => $tourist_id,
                                                 'message' =>$tourist_msg , 'created' => time()));
            $this->success();
        }else{
            $this->error();
        }
    }

    /**
     * 完成行程
     */
    public function finish()
    {
        $orderId = isset($_POST['order_id']) && is_numeric($_POST['order_id']) ? $_POST['order_id'] : null;
        if(!$orderInfo = $this->apporder_model
            ->orderDetail(array('ao.uid' => $this->user_id, 'ao.id' => $orderId))) $this->error('这不是你的订单！');
        if($orderInfo['status_id'] != 3 && $orderInfo['status_id'] != 32) $this->error("订单不是发货状态");

        $res = $this->apporder_model->updateOrder(array('status' => 99), array('id' => $orderId, 'uid' => $this->user_id));
        if($res){
            $this->apporderlog_model->addOrderLog(array('orderId' => $orderId,'log' =>"行程已经完成，哇吖将在1-2日内向玩伴执行打款操作",'created' => time()));
            $startDay = $orderInfo['startDay'];
            $endDay = $orderInfo['stopDay'];
            $title = $orderInfo['title'];
            $tourist_id = $this->user_id;
            $tourist_msg = "您已顺利完成{$startDay}至{$endDay}《{$title}》，别忘了到个人中心我的点评中给哇吖玩伴点评哦！";
            $this->notice_model->addNotice(array('sendUser' => '-10', 'receiveUser' => $tourist_id,
                                                 'message' =>$tourist_msg , 'created' => time()));
            if($orderInfo['telNum']){
                $tpl_id = 1196621;
                $tpl_value = "#start_date#={$startDay}&#end_date#={$endDay}&#service#={$title}";
                $this->mysms->send_sms_to_user_id($tpl_id, $tpl_value, '+'.$orderInfo['telCode'].$orderInfo['telNum']);
            }

            $this->success();
        }else{

        }
    }

    /**
     * 预定记录
     */
    public function orderlist()
    {
        //页码
        $page = 1;
        if(isset($_GET['page']) && is_numeric($_GET['page'])){
            $page = $_GET['page'];
        }
        $offset = ($page - 1) * $this->page_limit;

        //每页数量
        if(!isset($_GET['size']) || !is_numeric($_GET['size'])){
            $limit = $this->page_limit;
        }else{
            $limit = $_GET['size'];
        }

        if(isset($_GET['status']) && is_numeric($_GET['status']) && $_GET['status'] == 1){
            $orderlist = $this->apporder_model->getDealOrder(' a.shopId = '.$this->user_id.' and a.`status` = 1', $offset, $limit);
        }else{
            $orderlist = $this->apporder_model->getDealOrder(' a.shopId = '.$this->user_id.' and a.`status` != 1', $offset, $limit);
        }

        $this->success(array('data' => $orderlist, 'page' => $page));
    }

    /**
     * 预定订单详情
     */
    public function orderdetail()
    {
        if(!isset($_GET['id']) || !is_numeric($_GET['id'])) $this->error('order id not be null');
        $orderDetail = $this->apporder_model->orderDetail(array('ao.shopId' => $this->user_id, 'ao.id' => $_GET['id']), 'deal');

        $this->success(array('data' => $orderDetail));
    }

    /**
     * 处理预定
     */
    public function dealorder()
    {
        if(!isset($_POST['id']) || !is_numeric($_POST['id'])) $this->error('order id not be null');
        if(!isset($_POST['action']) || !is_numeric($_POST['action'])) $this->error('action id not be null');

        if(!$orderInfo = $this->apporder_model
            ->orderDetail(array('ao.uid' => $this->user_id, 'ao.id' => $_POST['id']))) $this->error('这不是你的订单！');

        $reason = isset($_POST['reason']) && strip_tags(trim($_POST['reason'])) && $_POST['action'] ? strip_tags($_POST['reason']) : null;
        $status = $_POST['action'] == 1 ? 3 : 2;

        $data = array('commentsSaler' => $reason, 'status' => $status, 'changed' => time());
        $where = array('id' => $_POST['id'], 'shopId' => $this->user_id);
        $update_res = $this->apporder_model->updateOrder($data, $where);
        if($update_res){
            if($status == 1){
                $this->apporderlog_model->addOrderLog(array(
                                                                'orderId' => $_POST['id'],
                                                                'log'     =>"玩伴接受了预定,行程将于".date('Y年m月d日',strtotime($orderInfo['startDay']))."开始",
                                                                'created' => time()
                                                            ));
                $start_date = date('Y年m月d日',strtotime($orderInfo['startDay']));
                $end_date = date('Y年m月d日',strtotime($orderInfo['endDay']));
                $title = $orderInfo['title'];
                $people_num = $orderInfo['persons'];
                $money = $orderInfo['moneyTotalRMB'];
                $user_name = $orderInfo['userName'];
                $mobile_tourist = '+'.$orderInfo['telCode'].$orderInfo['telNum'];
                $guider_info = $this->userv2_model->getUserv2(array('uid' => $this->user_id));
                //发送短信(用户)
                if($orderInfo['telNum']){
                    $tpl_id = 1196375;
                    $tpl_value = "#tourist#={$user_name}&#start_date#={$start_date}&#end_date#={$end_date}&#service#={$title}&#people_num#={$people_num}&#money#={$money}&#guide#={$guider_info['user_name']}&#phone_num#={$guider_info['telNum']}&#email#={$guider_info['email']}";
                    $this->mysms->send_sms_to_user_id($tpl_id, $tpl_value, $mobile_tourist);
                }
                //发送短信(玩伴)
                if($guider_info['telNum']){
                    $tpl_id = 1196395;
                    $tpl_value = "#date#=".$orderInfo['startDay'];
                    $this->mysms->send_sms_to_user_id($tpl_id, $tpl_value, '+'.$guider_info['telCode'].$guider_info['telNum']);
                }

                $order = array(
                    'title'      => $orderInfo['title'],
                    'start_date' => $start_date,
                    'end_date'   => $end_date,
                    'people_num' => $people_num,
                    'money'      => $money
                );
                $tourist = array('tourist_name' => $orderInfo['userName']);
                $guider = array(
                    'guider_name'              => $guider_info['userNmae'],
                    'mobile_guider'            => '+'.$guider_info['telCode'].$guider_info['telNum'],
                    'guider_mail'              => $guider_info['email'],
                    'guide_yudingjilu_address' => $this->url.'/index.php/user/orderlist'
                );
                $body = $this->emailBody($order, $tourist, $guider);
                //发送邮件（用户）
                if($orderInfo['email']){
                    $this->myemail->send_mail($orderInfo['email'],'预定成功',$body['tourist']);
                }
                //发送邮件（用户）
                if($orderInfo['email']){
                    $this->myemail->send_mail($guider_info['email'],'订单确认',$body['guider']);
                }
            }else{
                $this->apporderlog_model->addOrderLog(array(
                    'orderId' => $_POST['id'],
                    'log'     =>"玩伴拒绝了预定,原因:$reason",
                    'created' => time()
                ));

                $title = $orderInfo['title'];
                $guider_info = $this->userv2_model->getUserv2(array('uid' => $this->user_id));
                //发送短信(用户)
                if($orderInfo['telNum']){
                    $tpl_id = 1196351;
                    $tpl_value = "#guide#={$guider_info['userName']}&#service#={$title}";
                    $this->mysms->send_sms_to_user_id($tpl_id, $tpl_value, $guider_info['telNum']);
                }

                if($orderInfo['email']){
                    $tourist_yudingjilu_address = $this->url.'/index.php/user/orderlist';
                    $body = $this->reject_mail_body($guider_info['userName'], $title, $reason, $tourist_yudingjilu_address);
                    $this->myemail->send_mail($orderInfo['email'],'订单确认',$body['guider']);
                }
            }
        }
        $this->success();
    }

    /**
     * 评论列表
     */
    public function comments()
    {
        //页码
        $page = 1;
        if(isset($_GET['page']) && is_numeric($_GET['page'])){
            $page = $_GET['page'];
        }
        $offset = ($page - 1) * $this->page_limit;
        //每页数量
        if(!isset($_GET['size']) || !is_numeric($_GET['size'])){
            $limit = $this->page_limit;
        }else{
            $limit = $_GET['size'];
        }

        if(isset($_GET['iscomment']) && is_numeric($_GET['iscomment']) && $_GET['iscomment'] == 1){
            $whereData = array('uid' => $this->user_id, 'iscomment' => 1);
        }else{
            $whereData = array('uid' => $this->user_id, 'iscomment' => 0);
        }

        $commentsList = $this->trackcomments_model->getCommentsList($whereData, $offset, $limit);


        $this->success(array('data' => $commentsList, 'page' => $page));
    }

    /**
     * 添加评论
     */
    public function addcomment()
    {
        $guider_score = isset($_POST['guider_score']) && is_numeric($_POST['guider_score']) ? $_POST['guider_score'] : null;
        $track_score = isset($_POST['track_score']) && is_numeric($_POST['track_score']) ? $_POST['track_score'] : null;
        $oid = isset($_POST['oid']) && is_numeric($_POST['oid']) ? $_POST['oid'] : null;
        $comments = isset($_POST['comments']) && strlen($_POST['comments']) ? $_POST['comments'] : null;
        $type = isset($_POST['type']) && strlen($_POST['type']) && in_array($_POST['type'], array('TRACK', 'ACTIVITY', 'ZIYING')) ? $_POST['type'] : null;

        if($guider_score === null) $this->error('guider_score is not null');
        if($track_score === null) $this->error('track_score is not null');
        if($comments === null) $this->error('comments is not null');
        if($type === null) $this->error('type is not null');
        if($oid === null) $this->error('oid is not null');

        if(!$orderInfo = $this->apporder_model
                ->orderDetail(array('ao.uid' => $this->user_id, 'ao.id' => $oid, 'goodsType' => $type))) $this->error('这不是你的订单！');

        if($this->trackcomments_model->getComments(array('uid' => $this->user_id, 'oid' => $oid))) $this->error('该订单你已经评论过');

        //批量添加图片
        $this->load->library('Myupload', array('filePath' => self::COMMENTS_PIC));
        $comments_pic = '';
        $file_arr = array();
        if($_FILES['comments_pic']){
            for($i = 0; $i < count($_FILES['comments_pic']['name']); $i++){
                $file_arr[$i]['name'] = $_FILES['comments_pic']['name'][$i];
                $file_arr[$i]['type'] = $_FILES['comments_pic']['type'][$i];
                $file_arr[$i]['tmp_name'] = $_FILES['comments_pic']['tmp_name'][$i];
                $file_arr[$i]['error'] = $_FILES['comments_pic']['error'][$i];
                $file_arr[$i]['size'] = $_FILES['comments_pic']['size'][$i];
            }
        }

        foreach($file_arr as $k => $v) {
            $_FILES['comments_pic'] = $v;
            $identityRes = $this->myupload->doUpload('comments_pic');
            if ($identityRes['code']) {
                $comments_pic .= $identityRes['data']['upload_data']['full_path'].';';
            } else {
                $this->error('评论图片上传失败');
            }

        }

        //添加评论
        $this->trackcomments_model->addComments(array('uid' => $this->user_id,
                                                      'oid'          => $oid,
                                                      'track_id'     => $orderInfo['shopId'],
                                                      'track_name'     => $orderInfo['title'],
                                                      'tourist_pic'  => $comments_pic,
                                                      'comments'     => $orderInfo['title'],
                                                      'persons'      => $orderInfo['persons'],
                                                      'guider_id'    => $orderInfo['shopId'],
                                                      'track_score'  => $track_score,
                                                      'guider_score' => $guider_score,
                                                      'type'         => $type,
                                                      'created'      => time()
                                                      ));
        $this->success();
    }

    /**
     *
     *
     * 验证身份
     */
    public function checkidentity()
    {
        $save['identityErea']   = isset($_POST['identityErea']) && strlen($_POST['identityErea']) ? $_POST['identityErea'] : null;
        $save['identityName']   = isset($_POST['identityName']) && strlen($_POST['identityName']) ? $_POST['identityName'] : null;
        $save['identityActive'] = 0;
        $save['changed']        = time();

        if(!$save['identityErea'] || !$save['identityName']) $this->error('身份、职业不能为空！');

        //上传身份证和证件照
        $identityPic = $certificatePic = $save['identityPicture'] = '';
        $this->load->library('Myupload', array('filePath' => self::IDENTITY_PIC));
        $identityRes = $this->myupload->doUpload('identity');
        if($identityRes['code']){
            $identityPic = $identityRes['data']['upload_data']['full_path'];
        }else{
            $this->error('身份证上传失败');
        }

        $this->load->library('Myupload', array('filePath' => self::CERTIFICATE_PIC));
        $certificateRes = $this->myupload->doUpload('certificate');
        if($certificateRes['code']){
            $certificatePic = $certificateRes['data']['upload_data']['full_path'];
        }else{
            $this->error('证件照上传失败');
        }
        if($certificatePic || $identityPic) $save['identityPicture'] = $identityPic.';'.$certificatePic;

        //更新身份信息
        $this->userv2_model->editUser($save, array('uid' => $this->user_id));

        $this->success();
    }

    /**
     * 获取身份信息
     */
    public function getidentity()
    {
        $res = $this->userv2_model->getUserv2(array('uid' => $this->user_id), 'identityPicture,identityErea,identityName,identityActive');
        $res['identityPicture'] = $res['certificateResPicture'] = NULL;
        list($res['identityPicture'],$res['certificateResPicture'])
                    = $res['identityPicture'] ? explode(';', $res['identityPicture']) : array('', '');

        $this->success($res);
    }

    /**
     * 修改基本信息
     */
    public function edituserinfo()
    {
        $userinfodata['userFamily'] = isset($_POST['userFamily']) && strlen($_POST['userFamily']) ? $_POST['userFamily'] : null;
        $userinfodata['userName'] = isset($_POST['userName']) && strlen($_POST['userName']) ? $_POST['userName'] : null;
        $data['userGender'] = $userinfodata['userGender']  = isset($_POST['userGender']) && in_array($_POST['userGender'], array('f', 'm')) ? $_POST['userGender'] : 'f';
        $userinfodata['introduction'] = isset($_POST['introduction']) && strlen($_POST['introduction']) ? $_POST['introduction'] : null;
        $userinfodata['userAge'] = isset($_POST['userAge']) && strlen($_POST['userAge']) ? $_POST['userAge'] : null;
        $userinfodata['nationality'] = isset($_POST['nationality']) && strlen($_POST['nationality']) ? $_POST['nationality'] : null;
        $userinfodata['resideCity'] = isset($_POST['resideCity']) && strlen($_POST['resideCity']) ? $_POST['resideCity'] : null;
        $userinfodata['resideTime'] = isset($_POST['resideTime']) && strlen($_POST['resideTime']) ? $_POST['resideTime'] : null;
        $data['userName'] = $userinfodata['userFamily'].$userinfodata['userName'];

        $this->load->library('Myupload', array('filePath' => self::CERTIFICATE_PIC));
        $userIconRes = $this->myupload->doUpload('userIcon');
        if($userIconRes['code']){
            $userIcon = $userIconRes['data']['upload_data']['full_path'];
        }else{
            $this->error('证件照上传失败');
        }

        $data['userIcon'] = $userinfodata['userIcon'] = $userIcon;

        $this->userv2_model->editUser($data, array('uid' => $this->user_id));
        $this->userv2info_model->editUserInfo($userinfodata, array('uid' => $this->user_id));

        $this->success();
    }

    /**
     * 验证手机号
     */
    public function validatemobile()
    {
        $phone = isset($_POST['phoneNum']) && strlen($_POST['phoneNum']) ? $_POST['phoneNum'] : null;
        $areaCode = isset($_POST['areaCode']) && strlen($_POST['areaCode']) ? ltrim($_POST['areaCode'], '+') : null;
        $utype = isset($_POST['type']) && strlen($_POST['type']) && in_array($_POST['type'], array('GUIDER', 'TOURIST')) ? $_POST['type'] : 'TOURIST';
        $securimage_code_value = isset($_POST['securimage_code_value']) && strlen($_POST['securimage_code_value'])? $_POST['securimage_code_value'] : null;
        $smsCode = $this->userv2mobile_model->getSmsCode(array('mobile' => '+'.$areaCode.$phone));

        if(!$smsCode || $smsCode['code'] != $securimage_code_value) $this->error('验证码不正确!');
        if($this->userv2_model->getUserv2(array('telNum' => $phone, 'utype' => $utype))) $this->error('该手机号已经注册过');
        $data = array(
            'telNum'     => $phone,
            'telActive'  => 1,
            'changed'    => time(),
            'telCode'    => $areaCode,
            'utype'      => $utype,
        );
        $uid = $this->userv2_model->editUser($data, array('uid' => $this->user_id));
        if($uid > 0){
            $this->userv2info_model->editUserInfo(array('uid' => $uid, 'userPhone' => "+".$areaCode.trim($phone)), array('uid' => $this->user_id));

            $this->success();
        }else{
            $this->error();
        }
    }

    /**
     * 邮箱发送验证码
     */
    public function sendemailcode()
    {
        $email = isset($_POST['email']) && strlen($_POST['email']) && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) ? $_POST['email'] : null;
        $type = isset($_POST['type']) && strlen($_POST['type']) && in_array($_POST['type'], array('GUIDER', 'TOURIST')) ? $_POST['type'] : 'TOURIST';
        if($email === null) $this->error('邮箱格式不正确');
        $status = $this->myusersubscribe->user_activation_code($email,$mail_type=strtolower($type));
        if(!$status){
            $this->error('邮件发送失败');
        }else{
            $this->success();
        }
    }

    /**
     * 验证邮箱
     */
    public function validateemail()
    {
        $type = isset($_POST['type']) && strlen($_POST['type']) && in_array($_POST['type'], array('GUIDER', 'TOURIST')) ? $_POST['type'] : 'TOURIST';
        $email = isset($_POST['email']) && strlen($_POST['email']) && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) ? $_POST['email'] : null;
        $securimage_code_value = isset($_POST['securimage_code_value']) && strlen($_POST['securimage_code_value'])? $_POST['securimage_code_value'] : null;
        if(!check_email_code_value($securimage_code_value)) $this->error('验证码错误');
        if($email === null) $this->error('邮箱格式不正确');
        if($this->userv2_model->getUserv2(array('userId' => $email, 'utype' => 'TOURIST'))) $this->error('该邮箱已经注册过');

        $data = array(
            'email'     => $email,
            'changed'    => time(),
            'utype'      => $type,
            'status'      => 1,
            'active'      => 1,
        );
        $uid = $this->userv2_model->editUser($data, array('uid' => $this->user_id));
        if($uid > 0){
            $this->success();
        }else{
            $this->error();
        }
    }

    /**
     * 修改密码
     */
    public function editpassword()
    {
        $password = isset($_POST['password']) && strlen($_POST['password'])? $_POST['password'] : null;
        $re_password = isset($_POST['re_password']) && strlen($_POST['re_password'])? $_POST['re_password'] : null;
        $phone = isset($_POST['phoneNum']) && strlen($_POST['phoneNum']) ? $_POST['phoneNum'] : null;
        $areaCode = isset($_POST['areaCode']) && strlen($_POST['areaCode']) ? ltrim($_POST['areaCode'], '+') : null;
        $securimage_code_value = isset($_POST['securimage_code_value']) && strlen($_POST['securimage_code_value'])? $_POST['securimage_code_value'] : null;

        if($re_password != $password) $this->error('两次密码输入的不一样');

        if(!$this->userv2_model->getUser(array('uid' => $this->user_id, 'telActive' => 1))) $this->error('该用户未认证手机号');

        $smsCode = $this->userv2mobile_model->getSmsCode(array('mobile' => '+'.$areaCode.$phone));

        if(!$smsCode || $smsCode['code'] != $securimage_code_value) $this->error('验证码不正确!');
        if($this->userv2_model->getUserv2(array('telNum' => $phone, 'utype' => 'TOURIST'))) $this->error('该手机号已经注册过');
        $data = array(
            'telNum'     => $phone,
            'telActive'  => 1,
            'changed'    => time(),
            'telCode'    => $areaCode,
            'userToken'  => md5($password),
            'utype'      => 'TOURIST'
        );
        $uid = $this->userv2_model->createUser($data);
        if($uid > 0){
            $this->userv2info_model->createUserV2Info(array('uid' => $uid, 'userPhone' => "+".$areaCode.trim($phone)));

            $this->success();
        }else{
            $this->error();
        }
    }

    /**
     * 验证用户手机号是否验证
     */
    public function getmobile()
    {
        if($res = $this->userv2_model->getUser(array('uid' => $this->user_id, 'telActive' => 1), 'telNum,telCode')){
            $this->success($res);
        }else{
            $this->error();
        }
    }

    /**
     * 聊天记录列表
     */
    public function chat()
    {
        $rev_id = isset($_GET['rev_id']) && is_numeric($_GET['rev_id'])? $_GET['rev_id'] : null;
        if($rev_id === null) $this->error('聊天对象id不能为空');
        if($_SESSION['user_type'] == 'GUIDER'){
            $where = 'uc.uid = '.$rev_id.' and uc.guiderId = '.$this->user_id;
        }else{
            $where = 'uc.uid = '.$this->user_id.' and uc.guiderId = '.$rev_id;
        }
        $data = $this->userchat_model->getChatList($where, 0 ,10);
        $this->success($data);
    }

    /**
     * 私信列表
     */
    public function getchatgroup()
    {
        $data = $this->userchat_model->getChatByUser($this->user_id, $_SESSION['user_type']);
        $this->success($data);
    }

    /**
     * 添加聊天消息
     */
    public function addchat()
    {
        $rev_id = isset($_POST['rev_id']) && is_numeric($_POST['rev_id']) ? $_POST['rev_id'] : null;
        $text = isset($_POST['text']) && strlen($_POST['text'])? $_POST['text'] : null;
        if($rev_id === null) $this->error('聊天对象id不能为空');

        if (! empty($text))
        {
            $text = htmlspecialchars($text);
            $text = nl2br($text);
        }

        if(stripos($text,'#') !== FALSE){
            $search =array(
                "#呵呵#", "#哈哈#","#吐舌#", "#啊#","#酷#","#怒#", "#开心#", "#汗#", "#泪#", "#黑线#",
                "#鄙视#", "#不高兴#", "#真棒#", "#钱#", "#疑问#", "#阴脸#", "#吐#", "#咦#", "#委屈#",
                "#花心#", "#呼~#", "#笑脸#", "#冷#", "#太开心#", "#滑稽#", "#勉强#", "#狂汗#", "#乖#",
                "#睡觉#", "#惊哭#", "#生气#", "#惊讶#", "#喷#", "#爱心#", "#心碎#", "#玫瑰#", "#礼物#",
                "#彩虹#", "#星星月亮#", "#太阳#", "#钱币#", "#灯泡#","#茶杯#", "#蛋糕#", "#音乐#",
                "#haha#","#胜利#","#大拇指#", "#弱#","#OK#");
            foreach($search as $k=>$v){
                $k++;
                $text = str_replace($v, "<img src=\"/resource/skin/face/tieba/".$k.".png\" />", $text);
            }
        }
        if($_SESSION['user_type'] == 'GUIDER'){
            $this->userchat_model->addChat(array('uid' => $rev_id, 'guiderId' => $this->user_id, 'fromUser' => 0, 'status' => 1, 'message' => $text, 'created' => time()));
        }else{
            $this->userchat_model->addChat(array('uid' => $this->user_id, 'guiderId' => $rev_id, 'fromUser' => 1, 'status' => 1, 'message' => $text, 'created' => time()));
        }

        $this->success();
    }

    public function emailBody($order, $tourist, $guider)
    {
        $body['tourist'] = <<<DOC
                    <meta charset="utf-8">
<style type="text/css">
body{ margin:0 auto; padding:0; font-family:'微软雅黑',Hiragino Sans GB', '华文细黑', 'STHeiti', 'Microsoft YaHei',
SimHei, 'Helvetica Neue', Helvetica, Arial, sans-serif;background-color:#fff; font-size:12px;}

a{color:#00a2ca; line-height:22px; text-decoration:none;}
a:hover{text-decoration:underline;color:#489E85;}
td{font-family:'微软雅黑i';}
</style>


<table width="800" border="0" align="center" cellpadding="0" cellspacing="0" style="font-family:'微软雅黑';">
<tbody>
<tr>
        <td>
             <table style="width:800px;height:149px;">
             <tbody>
            <tr>
            <td><img src="http://www.wayatrip.com/resource/images/mail-imgs2.png" style="width:800px;height:149px;"></td>
            </tr>
             </tbody></table>
       </td>
</tr>

<tr>
        <td>
             <table style="width:800px;height:20px;">
             <tbody>
            <tr>
            <td width="800" height="30"></td>
            </tr>
             </tbody></table>
       </td>
</tr>

<tr>
        <td>

            <table width="800" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#fff" height="74" style="font-family:'微软雅黑';">
              <tbody><tr>
                <td width="97" height="74" border="0" align="center" valign="middle" style="padding-left:20px;"><a href="http://www.wayatrip.com" target="_blank"><img src="http://www.wayatrip.com/resource/www/imgs/logo.png" alt="哇吖自由行" width="97" height="74" border="0"></a>
               </td>
                <td width="703" height="74" colspan="2" align="left" valign="middle" style="padding-left:30px;">
                <font style="font-size:30px;color:#489E85;"><strong>订单确认</strong></font>
                </td>
              </tr>
            </tbody></table>

        </td>
</tr>

<tr>


        <td width="800" height="100" border="0" align="center" colspan="2" style="font-size:40px;vertical-align:middle;font-family:'微软雅黑';color:#F05C92">
<strong>预定成功!</strong>
        </td>
</tr>

<tr>
        <td>
             <table width="640" height="40" align="center" cellpadding="0" cellspacing="0" style="border:1px solid #C1F4E1;border-top-left-radius:4px;
border-top-right-radius:4px;background-color:#C1F4E1;color:#393939">
             <tbody>
            <tr>
            <td width="640" height="40" align="left" colspan="2" style="font-size:20px;vertical-align:middle;font-family:'微软雅黑';padding-left:20px;"> 详情</td>
            </tr>
             </tbody></table>
       </td>
</tr>

<tr>
        <td>
             <table align="center" cellpadding="0" cellspacing="0" style="width:640px;height:250px;border:1px solid #96EDCC;border-bottom-left-radius:4px;
border-bottom-right-radius:4px;background-color:#96EDCC;color:#393939">
             <tbody>
            <tr>
            <td width="640" height="50" align="left" colspan="2" style="font-size:20px;vertical-align:middle;font-family:'微软雅黑';padding-left:20px;">线路名称：<font style="font-size:30px">{$order['title']}</font></td>
            </tr>
            <tr>
            <td width="640" height="50" align="left" colspan="2" style="font-size:20px;vertical-align:middle;font-family:'微软雅黑';padding-left:20px;">游客姓名：<font style="font-size:30px">{$tourist['tourist_name']}</font></td>
            </tr>
            <tr>
            <td width="640" height="50" align="left" colspan="2" style="font-size:20px;vertical-align:middle;font-family:'微软雅黑';padding-left:20px;">出行日期：<font style="font-size:30px">{$order['start_date']}-{$$order['end_date']}</font></td>
            </tr>
            <tr>
            <td width="640" height="50" align="left" colspan="2" style="font-size:20px;vertical-align:middle;font-family:'微软雅黑';padding-left:20px;">出行人数：<font style="font-size:30px">{$order['people_num']}&nbsp;人</font></td>
            </tr>
            <tr>
            <td width="640" height="50" align="left" colspan="2" style="font-size:20px;vertical-align:middle;font-family:'微软雅黑';padding-left:20px;">支付金额：<font style="font-size:30px;color:#F05C92">{$order['money']}&nbsp;元</font></td>
            </tr>

             </tbody></table>
       </td>
</tr>

<tr>
        <td>
             <table style="width:800px;height:50px;">
             <tbody>
            <tr>
            <td width="800" height="50"></td>
            </tr>
             </tbody></table>
       </td>
</tr>

<tr>
        <td>
             <table width="640" height="240" align="center" cellpadding="0" cellspacing="0" style="border:1px solid #FAF2E6;border-radius:4px;
background-color:#FAF2E6;color:#393939;">
             <tbody>
            <tr>
            <td width="93" height="240" align="left" rowspan="6" style="vertical-align:middle;padding-left:20px;"><img src="http://www.wayatrip.com/resource/images/mail_imgs1.png" style="width:93px;height:240px;"></td>
            <td width="563" height="40" align="left" ></td>
            </tr>
            <tr>
            <td width="527" height="40" align="left" style="font-size:30px;vertical-align:middle;font-family:'微软雅黑';vertical-align:middle;padding-left:15px;">玩伴信息：</td>
            </tr>
            <tr>
            <td width="527" height="40" align="center" style="font-size:30px;vertical-align:middle;font-family:'微软雅黑';vertical-align:middle;">{$guider['guider_name']}</td>
            </tr>
            <tr>
            <td width="527" height="40" align="center" style="font-size:30px;vertical-align:middle;font-family:'微软雅黑';vertical-align:middle;">Tel：{$guider['mobile_guider']}</td>
            </tr>
            <tr>
            <td width="527" height="40" align="center" style="font-size:30px;vertical-align:middle;font-family:'微软雅黑';vertical-align:middle;">Email：{$guider['guider_mail']}</td>
            </tr>
            <tr>
            <td width="527" height="40"></td>
            </tr>

             </tbody></table>
       </td>
</tr>

<tr>

       <td width="800" height="100" border="0" align="center" colspan="2" style="font-size:20px;vertical-align:middle;font-family:'微软雅黑';">
如遇任何问题，请联系哇吖客服：&nbsp;&nbsp;<font style="color:#96EDCC"><strong>400-889-7955</strong></font>
       </td>

</tr>

<tr>
        <td>
             <table width="800" height="200" cellpadding="0" cellspacing="0" style="background-color:#252525;color:#fff;">
             <tbody>
            <tr>

            <td width="175" height="200"></td>

            <td>

            <table style="height:225px;width:200px;color:#fff;">
             <tbody>
            <tr>
            <td width="200" height="50" align="left" style="font-size:15px;vertical-align:middle;font-family:'微软雅黑';color:#fff;">联系我们</td>
            </tr>
            <tr>
            <td width="200" height="30" align="left" style="font-size:15px;vertical-align:middle;font-family:'微软雅黑';color:#fff;">国内：400-889-7955</td>
            </tr>
            <tr>
            <td width="200" height="30" align="left" style="font-size:15px;vertical-align:middle;font-family:'微软雅黑';color:#fff;">法国：+33666015304</td>
            </tr>
            <tr>
            <td width="200" height="30" align="left" style="font-size:15px;vertical-align:middle;font-family:'微软雅黑';color:#fff;">邮箱：info@wayatrip.com</td>
            </tr>
            <tr>
            <td width="200" height="60" align="left" ></td>
            </tr>
            </tbody></table>

           </td>
           <td>

            <table style="height:250px;width:200px;color:#fff;">
             <tbody>
            <tr>
            <td width="200" height="50" align="center" style="font-size:15px;vertical-align:middle;font-family:'微软雅黑';padding-top:10px;color:#fff;">官方微信<br/>wayaziyouxing</td>
            </tr>
            <tr>
            <td width="200" height="100" align="center"><img src="http://www.wayatrip.com/resource/www/imgs/erweima.jpg" style="height:100px;width:100px"></td>
            </tr>
            <tr>
            <td width="200" height="50" ></td>
            </tr>
            </tbody></table>

           </td>

           <td width="150" height="200"></td>
            </tr>
             </tbody></table>
       </td>
</tr>
</tbody></table>
DOC;
        $body['guider'] = <<<DOC
<meta charset="utf-8">
<style type="text/css">
body{ margin:0 auto; padding:0; font-family:'微软雅黑',Hiragino Sans GB', '华文细黑', 'STHeiti', 'Microsoft YaHei',
SimHei, 'Helvetica Neue', Helvetica, Arial, sans-serif;background-color:#fff; font-size:12px;}
a{color:#00a2ca; line-height:22px; text-decoration:none;}
a:hover{text-decoration:underline;color:#489E85;}
td{font-family:'微软雅黑i';}
</style>
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0" style="font-family:'微软雅黑';">
<tbody>
<tr>
        <td>
             <table style="width:800px;height:149px;">
             <tbody>
            <tr>
            <td><img src="http://www.wayatrip.com/resource/images/mail-imgs2.png" style="width:800px;height:149px;"></td>
            </tr>
             </tbody></table>
       </td>
</tr>
<tr>
        <td>
             <table style="width:800px;height:20px;">
             <tbody>
            <tr>
            <td width="800" height="30"></td>
            </tr>
             </tbody></table>
       </td>
</tr>
<tr>
        <td>

            <table width="800" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#fff" height="74" style="font-family:'微软雅黑';">
              <tbody><tr>
                <td width="97" height="74" border="0" align="center" valign="middle" style="padding-left:20px;"><a href="http://www.wayatrip.com" target="_blank"><img src="http://www.wayatrip.com/resource/www/imgs/logo.png" alt="哇吖自由行" width="97" height="74" border="0"></a>
               </td>
                <td width="703" height="74" colspan="2" align="left" valign="middle" style="padding-left:30px;">
                <font style="font-size:30px;color:#489E85;"><strong>玩伴接受预定</strong></font>
                </td>
              </tr>
            </tbody></table>

        </td>
</tr>
<tr>
        <td width="800" height="100" border="0" align="center" colspan="2" style="font-size:20px;vertical-align:middle;font-family:'微软雅黑';">
<strong>您已接受&nbsp;<font style="font-size:40px;">{$tourist['tourist_name']}</font>&nbsp;先生/女士关于&nbsp;<font style="font-size:40px;">{$order['title']}</font>&nbsp;的预定申请</strong>
        </td>
</tr>
<tr>
        <td>
             <table style="width:800px;height:20px;">
             <tbody>
            <tr>
            <td width="800" height="30"></td>
            </tr>
             </tbody></table>
       </td>
</tr>
<tr>
        <td>
             <table width="640" height="40" align="center" cellpadding="0" cellspacing="0" style="border:1px solid #C1F4E1;border-top-left-radius:4px;
border-top-right-radius:4px;background-color:#C1F4E1;color:#393939">
             <tbody>
            <tr>
            <td width="640" height="40" align="left" colspan="2" style="font-size:20px;vertical-align:middle;font-family:'微软雅黑';padding-left:20px;">详情</td>
            </tr>
             </tbody></table>
       </td>
</tr>
<tr>
        <td>
             <table align="center" cellpadding="0" cellspacing="0" style="width:640px;height:150px;background-color:#96EDCC;color:#393939">
             <tbody>
            <tr>
            <td width="640" height="50" align="left" colspan="2" style="font-size:20px;vertical-align:middle;font-family:'微软雅黑';padding-left:20px;">出行日期：<font style="font-size:30px">{$order['start_date']}-{$order['end_date']}</font></td>
            </tr>
            <tr>
            <td width="640" height="50" align="left" colspan="2" style="font-size:20px;vertical-align:middle;font-family:'微软雅黑';padding-left:20px;">出行人数：<font style="font-size:30px">{$order['people_num']}&nbsp;人</font></td>
            </tr>
            <tr>
            <td width="640" height="50" align="left" colspan="2" style="font-size:20px;vertical-align:middle;font-family:'微软雅黑';padding-left:20px;">支付金额：<font style="font-size:30px;color:#F05C92">{$order['money']}&nbsp;元</font><br/><br/><br/><font style="font-size:12px;">游客支付金额=玩伴制定的路线或是活动的价格*110%<br/>(该资金由哇吖托管至旅行结束，届时哇吖将向玩伴执行打款操作，打款金额为玩伴制定的路线或是活动的价格)</font></td>
            </tr>

             </tbody></table>
       </td>
</tr>
<tr>
        <td>
             <table align="center" cellpadding="0" cellspacing="0" style="width:640px;height:30px;background-color:#96EDCC;border:1px solid #96EDCC;border-bottom-left-radius:4px;
border-bottom-right-radius:4px;">
             <tbody>
            <tr>
            <td width="800" height="30"></td>
            </tr>
             </tbody></table>
       </td>
</tr>
<tr>
        <td>
             <table style="width:800px;height:50px;">
             <tbody>
            <tr>
            <td width="800" height="50"></td>
            </tr>
             </tbody></table>
       </td>
</tr>
<tr>
       <td>
       <table align="center" cellpadding="0" cellspacing="0" style="width:200px;height:50px;border:1px solid #F05C92;border-radius:4px;
background-color:#F05C92;vertical-align:middle;">
             <tbody>
            <tr>
            <td style="font-size:20px;vertical-align:middle;font-family:'微软雅黑';padding-left:60px;width:200px;height:50px;">
            <a href="{$guider['guide_yudingjilu_address']}" target="_blank" style="text-decoration:none;color:#fff;width:200px;height:50px;">查看订单</a>
            </td>
            </tr>
             </tbody></table>
       </td>
</tr>
<tr>
        <td>
             <table style="width:800px;height:30px;">
             <tbody>
            <tr>
            <td width="800" height="30"></td>
            </tr>
             </tbody></table>
       </td>
</tr>
<tr>
        <td>
             <table style="width:800px;height:50px;text-align:center;vertical-align:middle">
             <tbody>
            <tr>
            <td style="font-size:15px;">如无法点击，复制以下地址至浏览器打开<br/>{$guider['guide_yudingjilu_address']}</td>
            </tr>
             </tbody></table>
       </td>
</tr>
<tr>
        <td>
             <table style="width:800px;height:30px;">
             <tbody>
            <tr>
            <td width="800" height="30"></td>
            </tr>
             </tbody></table>
       </td>
</tr>
<tr>
        <td>
             <table width="800" height="200" cellpadding="0" cellspacing="0" style="background-color:#252525;color:#fff;">
             <tbody>
            <tr>
            <td width="175" height="200"></td>
            <td>
            <table style="height:225px;width:200px;color:#fff;">
             <tbody>
            <tr>
            <td width="200" height="50" align="left" style="font-size:15px;vertical-align:middle;font-family:'微软雅黑';color:#fff;">联系我们</td>
            </tr>
            <tr>
            <td width="200" height="30" align="left" style="font-size:15px;vertical-align:middle;font-family:'微软雅黑';color:#fff;">国内：400-889-7955</td>
            </tr>
            <tr>
            <td width="200" height="30" align="left" style="font-size:15px;vertical-align:middle;font-family:'微软雅黑';color:#fff;">法国：+33666015304</td>
            </tr>
            <tr>
            <td width="200" height="30" align="left" style="font-size:15px;vertical-align:middle;font-family:'微软雅黑';color:#fff;">邮箱：info@wayatrip.com</td>
            </tr>
            <tr>
            <td width="200" height="60" align="left" ></td>
            </tr>
            </tbody></table>
           </td>
           <td>
            <table style="height:250px;width:200px;color:#fff;">
             <tbody>
            <tr>
            <td width="200" height="50" align="center" style="font-size:15px;vertical-align:middle;font-family:'微软雅黑';padding-top:10px;color:#fff;">官方微信<br/>wayaziyouxing</td>
            </tr>
            <tr>
            <td width="200" height="100" align="center"><img src="http://www.wayatrip.com/resource/www/imgs/erweima.jpg" style="height:100px;width:100px"></td>
            </tr>
            <tr>
            <td width="200" height="50" ></td>
            </tr>
            </tbody></table>
           </td>
           <td width="150" height="200"></td>
            </tr>
             </tbody></table>
       </td>
</tr>
</tbody></table>
DOC;
        return $body;
    }

    public function reject_mail_body($guider_name, $title, $reason, $tourist_yudingjilu_address)
    {
        return $body = <<<DOC
<meta charset="utf-8">
<style type="text/css">
body{ margin:0 auto; padding:0; font-family:'微软雅黑',Hiragino Sans GB', '华文细黑', 'STHeiti', 'Microsoft YaHei',
SimHei, 'Helvetica Neue', Helvetica, Arial, sans-serif;background-color:#fff; font-size:12px;}

a{color:#00a2ca; line-height:22px; text-decoration:none;}
a:hover{text-decoration:underline;color:#489E85;}
td{font-family:'微软雅黑i';}
</style>
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0" style="font-family:'微软雅黑';">
<tbody>
<tr>
        <td>
             <table style="width:800px;height:149px;">
             <tbody>
            <tr>
            <td><img src="http://www.wayatrip.com/resource/images/mail-imgs2.png" style="width:800px;height:149px;"></td>
            </tr>
             </tbody></table>
       </td>
</tr>

<tr>
        <td>
             <table style="width:800px;height:20px;">
             <tbody>
            <tr>
            <td width="800" height="30"></td>
            </tr>
             </tbody></table>
       </td>
</tr>
<tr>
        <td>

            <table width="800" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#fff" height="74" style="font-family:'微软雅黑';">
              <tbody><tr>
                <td width="97" height="74" border="0" align="center" valign="middle" style="padding-left:20px;"><a href="http://www.wayatrip.com" target="_blank"><img src="http://www.wayatrip.com/resource/www/imgs/logo.png" alt="哇吖自由行" width="97" height="74" border="0"></a>
               </td>
                <td width="703" height="74" colspan="2" align="left" valign="middle" style="padding-left:30px;">
                <font style="font-size:30px;color:#489E85;"><strong>抱歉！您的预定被玩伴拒绝</strong></font>
                </td>
              </tr>
            </tbody></table>

        </td>
</tr>
<tr>
        <td width="600" height="100" border="0" align="center" colspan="2" style="font-size:20px;vertical-align:middle;font-family:'微软雅黑';">
<strong>玩伴&nbsp;<font style="font-size:40px;">{$guider_name}</font>&nbsp;拒绝了您关于&nbsp;<font style="font-size:40px;">{$title}</font>&nbsp;的预定申请</strong>
        </td>
</tr>
<tr>
        <td>
             <table style="width:800px;height:20px;">
             <tbody>
            <tr>
            <td width="800" height="30"></td>
            </tr>
             </tbody></table>
       </td>
</tr>
<tr>
        <td>
             <table width="640" height="40" align="center" cellpadding="0" cellspacing="0" style="border:1px solid #C1F4E1;border-top-left-radius:4px;
border-top-right-radius:4px;background-color:#C1F4E1;color:#393939">
             <tbody>
            <tr>
            <td width="640" height="40" align="left" colspan="2" style="font-size:20px;vertical-align:middle;font-family:'微软雅黑';padding-left:20px;">拒绝原因：</td>
            </tr>
             </tbody></table>
       </td>
</tr>
<tr>
        <td>
             <table align="center" cellpadding="0" cellspacing="0" style="width:640px;height:150px;border:1px solid #96EDCC;border-bottom-left-radius:4px;
border-bottom-right-radius:4px;background-color:#96EDCC;color:#393939">
             <tbody>
            <tr>
            <td width="640" height="50" align="left" colspan="2" style="font-size:20px;vertical-align:middle;font-family:'微软雅黑';padding-left:20px;">
            {$reason}</td>
            </tr>

             </tbody></table>
       </td>
</tr>
<tr>
        <td>
             <table style="width:800px;height:50px;">
             <tbody>
            <tr>
            <td width="800" height="50"></td>
            </tr>
             </tbody></table>
       </td>
</tr>
<tr>
       <td>
       <table align="center" cellpadding="0" cellspacing="0" style="width:200px;height:50px;border:1px solid #F05C92;border-radius:4px;
background-color:#F05C92;vertical-align:middle;">
             <tbody>
            <tr>
            <td style="font-size:20px;vertical-align:middle;font-family:'微软雅黑';padding-left:60px;width:200px;height:50px;">
            <a href="{$tourist_yudingjilu_address}" target="_blank" style="text-decoration:none;color:#fff;width:200px;height:50px;">查看订单</a>
            </td>
            </tr>
             </tbody></table>
       </td>
</tr>
<tr>
        <td>
             <table style="width:800px;height:30px;">
             <tbody>
            <tr>
            <td width="800" height="30"></td>
            </tr>
             </tbody></table>
       </td>
</tr>
<tr>
        <td>
             <table style="width:800px;height:50px;text-align:center;vertical-align:middle">
             <tbody>
            <tr>
            <td style="font-size:15px;">如无法点击，复制以下地址至浏览器打开<br/>{$tourist_yudingjilu_address}</td>
            </tr>
             </tbody></table>
       </td>
</tr>
<tr>
        <td>
             <table style="width:800px;height:30px;">
             <tbody>
            <tr>
            <td width="800" height="30"></td>
            </tr>
             </tbody></table>
       </td>
</tr>
<tr>
        <td>
             <table width="800" height="200" cellpadding="0" cellspacing="0" style="background-color:#252525;color:#fff;">
             <tbody>
            <tr>
            <td width="175" height="200"></td>
            <td>
            <table style="height:225px;width:200px;color:#fff;">
             <tbody>
            <tr>
            <td width="200" height="50" align="left" style="font-size:15px;vertical-align:middle;font-family:'微软雅黑';color:#fff;">联系我们</td>
            </tr>
            <tr>
            <td width="200" height="30" align="left" style="font-size:15px;vertical-align:middle;font-family:'微软雅黑';color:#fff;">国内：400-889-7955</td>
            </tr>
            <tr>
            <td width="200" height="30" align="left" style="font-size:15px;vertical-align:middle;font-family:'微软雅黑';color:#fff;">法国：+33666015304</td>
            </tr>
            <tr>
            <td width="200" height="30" align="left" style="font-size:15px;vertical-align:middle;font-family:'微软雅黑';color:#fff;">邮箱：info@wayatrip.com</td>
            </tr>
            <tr>
            <td width="200" height="60" align="left" ></td>
            </tr>
            </tbody></table>
           </td>
           <td>
            <table style="height:250px;width:200px;color:#fff;">
             <tbody>
            <tr>
            <td width="200" height="50" align="center" style="font-size:15px;vertical-align:middle;font-family:'微软雅黑';padding-top:10px;color:#fff;">官方微信<br/>wayaziyouxing</td>
            </tr>
            <tr>
            <td width="200" height="100" align="center"><img src="http://www.wayatrip.com/resource/www/imgs/erweima.jpg" style="height:100px;width:100px"></td>
            </tr>
            <tr>
            <td width="200" height="50" ></td>
            </tr>
            </tbody></table>
           </td>
           <td width="150" height="200"></td>
            </tr>
             </tbody></table>
       </td>
</tr>
</tbody></table>
DOC;
    }

}